﻿using HZH_Controls.Controls;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 渐变.user_Form
{
    public partial class user_MyMsg : Form
    {
        public user_MyMsg()
        {
            InitializeComponent();
        }
        public string opname { get; set; }
        private void ucDataGridView1_Load(object sender, EventArgs e)
        {
            List<DataGridViewColumnEntity> lstCulumns = new List<DataGridViewColumnEntity>();
            lstCulumns.Add(new DataGridViewColumnEntity() { DataField = "cid", HeadText = "编号", Width = 30, WidthType = SizeType.AutoSize });
            lstCulumns.Add(new DataGridViewColumnEntity() { DataField = "carname", HeadText = "车名", Width = 30, WidthType = SizeType.AutoSize });
            lstCulumns.Add(new DataGridViewColumnEntity() { DataField = "carid", HeadText = "车牌号", Width = 40, WidthType = SizeType.AutoSize });
            lstCulumns.Add(new DataGridViewColumnEntity() { DataField = "carproblem", HeadText = "问题", Width = 80, WidthType = SizeType.AutoSize });
            lstCulumns.Add(new DataGridViewColumnEntity() { DataField = "handlepeople", HeadText = "处理人", Width = 30, WidthType = SizeType.AutoSize });
            lstCulumns.Add(new DataGridViewColumnEntity() { DataField = "handMsg", HeadText = "待隐藏", Width = 30, WidthType = SizeType.AutoSize });            
            lstCulumns.Add(new DataGridViewColumnEntity() { DataField = "handTime", HeadText = "处理时间", Width = 50, WidthType = SizeType.AutoSize, Format = (a) => { return ((DateTime)a).ToString("yyyy-MM-dd HH:mm:ss"); } });
            this.ucDataGridView1.Columns = lstCulumns;
            // this.ucDataGridView1.IsShowCheckBox = true;
            string sql = "select * from complaint where isHandle='True' and cname=@cname";
            SqlParameter p = new SqlParameter("@cname", this.opname);
            DataTable dt = new DataTable();
            dt = DBHelper.ExecuteQuery(sql,p);
            this.ucDataGridView1.DataSource = dt;
           // this.ucDataGridView1.First();
        }

        private void ucDataGridView1_ItemClick(object sender, DataGridViewEventArgs e)
        {
            var row = ucDataGridView1.SelectRow;
            if (row.DataSource != null)
            {
                string handMsg = (ucDataGridView1.SelectRow.DataSource as DataRow)["handMsg"].ToString();

                user_viewMsg viewMsg = new user_viewMsg();
                viewMsg.StartPosition = FormStartPosition.CenterParent;
                viewMsg.msg = handMsg;
                viewMsg.ShowDialog();

            }

        }

        private void ucDataGridView1_Click(object sender, EventArgs e)
        {
           
        }

        private void user_MyMsg_Load(object sender, EventArgs e)
        {
            this.Dock = DockStyle.Fill;
        }
    }
}
